<template>
	<view class="contain">




		<view class="flex-col flex-auto group">
		  <view class="flex-col group_2 space-y-16">

		    <view class="flex-col space-y-12">
								   <view class="flex-col list-item_3 space-y-16" v-for="(item, index) in list" :key="index">
								     <view class="flex-col group_6 space-y-16">
								       <text class="self-start font_1">发布时间：{{item.createTime | time}}</text>
								       <view class="flex-row items-center space-x-25">
								         <image  class="image_6" :src="item.cover" mode="aspectFill" />
								         <view class="flex-col space-y-10">
								           <view class="flex-row items-center space-x-8">
								             <image
								               class="image_7"
								               src="https://qiniu.ccchongya.com/chongya/images/16947555487831642959.png"
								             />
								             <text class="font_3 text_10">{{item.title}}</text>
								             <view class="flex-col justify-start items-center text-wrapper_2" v-if="item.petBreeds"><text class="font_2">{{item.petBreeds}}</text></view>
								           </view>
								           <text class="font_1">{{item.intro}}</text>
								           <view class="flex-row space-x-8">
								             <!-- <view class="flex-col justify-start items-center text-wrapper_3"><text class="font_2">{{item.petBreeds}}</text></view> -->
								             <view class="flex-col justify-start items-center text-wrapper_3"  v-if="item.petStatus"><text class="font_2">{{item.petStatus}}</text></view>
								             <view class="flex-col justify-start items-center text-wrapper_3"  v-if="item.petAge"><text class="font_2">{{item.petAge}}</text></view>
								             <view class="flex-col justify-start items-center text-wrapper_3"  v-if="item.petMedicine">
								               <text class="font_2 text_11">{{item.petMedicine}}</text>
								             </view>
								           </view>
								         </view>
								       </view>
								     </view>
								     <view class="flex-col group_7 space-y-8" >
								       <text class="self-start font_4">领养要求：</text>
								       <text class="font_4 text_12">{{item.content}}</text>
								     </view>
								     <view class="flex-row justify-between group_8" @tap="makePhone(item.mobile)">
								       <text class="font_4">领养电话：{{item.mobile}}</text>
								       <image
								         class="image_8"
								         src="https://qiniu.ccchongya.com/chongya/images/16947555483658337900.png"
								       />
								     </view>
								   </view>

		      </view>
		    </view>
		  </view>



							 <div @click="go('/pages/other/adopt/add')"
							 style="word-wrap: break-word;font-size:30rpx;width:120rpx;height:120rpx;padding:20rpx;text-align:center;position: fixed;bottom:200rpx;right:50rpx;background:#ffc300 ;color:#fff;border-radius: 50%;">
							 	发布领养
							 </div>


			<view style="padding-top: 1px;"></view>
			<view class="padding-lr15">
				<view @click="choose(item)" v-for="item in list" class="flex bg-color-w bg-shadow-0 padding-tb12 margin-t12 b-radius-8" 		@longtap="deleteAddress(item.id)">


					<view class="flex f-a-c padding-lr12">
						<text class="flex f-a-c f-j-c van-icon  f20-size" :class="item.id == id ? 'van-icon-checked t-color-y' : 'van-icon-circle t-color-9'"></text>
					</view>
					<view class="flex flex-1 f-c">
						<view class="flex f-a-c">
							<text v-if="item.status == 1" class="f10-size padding-lr2 b-radius-2  t-color-w margin-r4" style="background-color: #CDE676;">{{i18n['默认']}}</text>
							<text class="f15-size">{{item.realname}}  {{item.phone}}</text>
						</view>
						<view class="flex f-a-c margin-t2">
							<text class="f12-size t-color-9">{{item.province}}{{item.city}}{{item.area}} {{item.address}}</text>
						</view>
					</view>
					<view @click.stop="edit(item)" class="flex f-a-c padding-lr12">
						<text class="flex f-a-c f-j-c van-icon van-icon-editor f20-size"></text>
					</view>
				</view>
			</view>
			<no-data v-if="list.length <= 0"></no-data>
			<view class="padding-15"></view>
			<view class="padding-30"></view>
		<view class="warp-tabbar bg-color-w flex f-a-c padding-lr15" :style="{'padding-bottom': isIphonex ? '34px' : ''}">
			<view @click="go('/pages/user/addaddress')" class="flex f-a-c f-j-c flex-1 bg-color-linear-y t-color-w b-radius-30 h-40">
				<text class="flex f-a-c f-j-c van-icon van-icon-plus t-color-w margin-r6"></text>
				<text class="t-color-w f15-size f-w-500">{{i18n['增加新地址']}}</text>
			</view>
		</view>
	</view>
</template>
<style scoped>
@import url('@/static/css/user/address.css');
</style>
<script>
	const API = require('@/utils/api/order.js').default;
	const $ = require('@/utils/api.js');
	export default {
		data() {
			return {
				top: uni.getStorageSync('bartop') ? uni.getStorageSync('bartop') : 0,
				isIphonex: uni.getStorageSync('isIphonex') ? uni.getStorageSync('isIphonex') : false,
				list: [],
				type: '',
				id: '',
			};
		},
		onLoad: function(options) {
			this.type = options.type ? options.type : '';
			this.id = options.id ? options.id : '';
			// this.init();
			$.setTitle(this.i18n['收货地址'])
		},
		onShow: function() {
			this.init();
		},
		methods: {
			deleteAddress(id) {
				uni.showModal({
					content: '确定要删除吗',
					success: e => {
						if (e.confirm) {
							// this.handleAddressDelete(id);
						}
					}
				});
			},
			choose(item) {
				const self = this;
				if(this.type != '') {
					if(this.type == 'change') {//订单修改地址
						$.ajax({
							url: API.changeAddressApi,
							data: {
								orderId: self.id,
								addressId: item.id,
							},
							method: 'POST',
							success(res) {
								$.$toast(self.i18n['操作成功']);
								self.back(1,2000)
							}
						})
						return;
					}
					console.log("aaaa")
					let pages = getCurrentPages(); // 当前页面
					let beforePage = pages[pages.length - 2]; // 前一个页面
					let len = 1;
					uni.navigateBack({
						delta: len,
						success: function() {
							if (beforePage.$vm.setAddress) {
								beforePage.$vm.setAddress(item); // 执行前一个页面的changeBanner方法
							}
						}
					});
				}
			},
			edit(item) {
				uni.setStorageSync('addressinfo',item);
				this.go('/pages/user/addaddress?id='+item.id);
			},
			getList() {
				const self = this;
				$.ajax({
					url: 'member/address/getList',
					data: {
						page: 1,
						pageSize: 99
					},
					method: 'GET',
					success(res) {
						self.list = res.data.list ? res.data.list : [];
					}
				})
			},
			init() {
				this.getList();
			},


		},
		computed: {
			i18n() {
				return this.$t('address')
			},
		},
		created() {
		},
		mounted() {},
		destroyed() {},
		components: {},
		onPullDownRefresh() {
		},
		onReachBottom() {
		}
	}
</script>



<style scoped>
	page {

	background-image: linear-gradient(180deg, #ffc300 6.5%, #ffffff 60.8%);
	width: 100%;
/* 	overflow-y: auto;
	overflow-x: hidden; */
	height: 100%;
	padding-top:60rpx
	}
	.group_2 {
	padding: 0 24rpx;
	}
	.group_3 {
	padding-left: 8rpx;
	}
	.image_4 {
	width: 38rpx;
	height: 38rpx;
	}
	.font_1 {
	font-size: 24rpx;
	font-family: HarmonyOSSansSC;
	line-height: 22rpx;
	color: #666e7a;
	}
	.text_2 {
	margin-left: 16rpx;
	color: #081329;
	}
	.section {
	margin-left: 44rpx;
	padding-left: 16rpx;
	background-color: #ffffff;
	border-radius: 342rpx;
	height: 62rpx;
	border: solid 2rpx #ffbd52;
	}
	.image_5 {
	width: 32rpx;
	height: 30rpx;
	}
	.font_2 {
	font-size: 20rpx;
	font-family: HarmonyOSSansSC;
	line-height: 18rpx;
	color: #ffffff;
	}
	.text_3 {
	color: #6d6a6b;
	line-height: 19rpx;
	}
	.text-wrapper {
	padding: 20rpx 0;
	background-color: #ffbd52;
	border-radius: 194rpx;
	width: 108rpx;
	height: 60rpx;
	}
	.text_4 {
	color: #ffffff;
	}
	.space-y-12 > view:not(:first-child),
	.space-y-12 > text:not(:first-child),
	.space-y-12 > image:not(:first-child) {
	margin-top: 24rpx;
	}
	.list-item {
	padding: 32rpx 16rpx 48rpx 32rpx;
	background-color: #ffffff;
	border-radius: 20rpx;
	filter: drop-shadow(0px 0px 8rpx #ffbd5208);
	overflow: hidden;
	}
	.image_6 {
	border-radius: 398rpx;
	width: 160rpx;
	height: 160rpx;
	}
	.group_4 {
	margin: 8rpx 0 8rpx 50rpx;
	}
	.space-x-8 > view:not(:first-child),
	.space-x-8 > text:not(:first-child),
	.space-x-8 > image:not(:first-child) {
	margin-left: 16rpx;
	}
	.image_7 {
	width: 32rpx;
	height: 32rpx;
	}
	.font_3 {
	font-size: 32rpx;
	font-family: HarmonyOSSansSC;
	line-height: 26rpx;
	color: #081329;
	}
	.text_5 {
	line-height: 27rpx;
	}
	.text-wrapper_2 {
	padding: 12rpx;
	background-color: #4578ff;
	border-radius: 4rpx;
	/* width: 80rpx; */
	height: 40rpx;
	}
	.text_6 {
	line-height: 24rpx;
	}
	.text-wrapper_3 {
	padding: 12rpx 0;
	background-color: #ffbd52;
	border-radius: 370rpx;
	width: 80rpx;
	height: 40rpx;
	}
	.text_7 {
	line-height: 19rpx;
	}
	.space-y-10 > view:not(:first-child),
	.space-y-10 > text:not(:first-child),
	.space-y-10 > image:not(:first-child) {
	margin-top: 20rpx;
	}
	.space-y-16 > view:not(:first-child),
	.space-y-16 > text:not(:first-child),
	.space-y-16 > image:not(:first-child) {
	margin-top: 32rpx;
	}

	.list-item_3 {
	padding: 0 28rpx 36rpx 32rpx;
	background-color: #ffffff;
	border-radius: 20rpx;
	filter: drop-shadow(0px 0px 8rpx #ffbd5208);
	overflow: hidden;
	}
	.group_6 {
	padding: 32rpx 4rpx 44rpx;
	border-bottom: solid 1.2rpx #0000002b;
	}
	.space-y-16 > view:not(:first-child),
	.space-y-16 > text:not(:first-child),
	.space-y-16 > image:not(:first-child) {
	margin-top: 32rpx;
	}
	.space-x-25 > view:not(:first-child),
	.space-x-25 > text:not(:first-child),
	.space-x-25 > image:not(:first-child) {
	margin-left: 50rpx;
	}
	.text_10 {
	line-height: 27rpx;
	}
	.text_11 {
	line-height: 19rpx;
	}
	.group_7 {
	padding: 40rpx 4rpx 0;
	}
	.space-y-8 > view:not(:first-child),
	.space-y-8 > text:not(:first-child),
	.space-y-8 > image:not(:first-child) {
	margin-top: 16rpx;
	}
	.font_4 {
	font-size: 28rpx;
	line-height: 26rpx;
	color: #000000;
	}
	.text_12 {
	color: #081329a8;
	line-height: 44rpx;
	}
	.group_8 {
	margin-top: 52rpx;
	padding: 0 4rpx;
	}
	.image_8 {
	margin-right: 20rpx;
	width: 28rpx;
	height: 28rpx;
	}
</style>
